<template>
  <div v-text="content"></div>
</template>

<script lang="ts" setup>
import { Toast } from 'vant';
import { onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
const route = useRoute()
const router = useRouter()
const content = ref('')
onMounted(async ()=>{
  if (route.query.code) {
    try {
      content.value = route.query.code.toString()
      localStorage.setItem('code',route.query.code.toString())
      // let redirectUrl = sessionStorage.getItem("wxRedirectUrl");
      // let res = await this.$api.getWxUserInfo({
      //   wxCode: route.query.code
      // });
      // if (res.data.code == 200) {
      //  //将一些信息存储到本地
      //   const token = res.headers['accesstoken']
      //   localStorage.setItem('token', token)
      //   localStorage.setItem("wxUserInfo", JSON.stringify(res.data.root));
      //   localStorage.setItem("openId", res.data.root.openId);
      // }
      // router.replace('/');//跳转到业务页面
    } catch (error) {
      console.log(error);
    }
  } else {
   // 如果不是从微信重定向过来的，没有带着微信的 code，则直接进入首页
    router.replace('/');
  }
})

</script>

<style lang="scss" scoped>
</style>